import wireformat;
class SearchRequest : Message 
{
	string  query_="cc";
	int  quersy_=1;
	int _cached_size_;
	byte[] _unknown_fields;
	byte[] unknown_fields()
	{
		return _unknown_fields;
	}
	byte[] mutable_unknown_fields()
	{
		return _unknown_fields.dup;
	}
	int GetCachedSize()
	{
		return _cached_size_;
	}
	void SetCachedSize(int size )
	{
		_cached_size_ = size;
		 
	}
	uint _has_bits_[(2 + 31 ) / 32];
	bool has_bit(int index )
	{
		return (_has_bits_[index / 32] & (1u << (index % 32 ))) != 0;
	}
	void set_bit(int index )
	{
		_has_bits_[index / 32] |= (1u << (index % 32 ));
	}
	void clear_bit(int index )
	{
		_has_bits_[index / 32] &= ~(1u << (index % 32 ));
	}
	bool has_query()
	{
		return has_bit(1 );
	}
	void clear_query()
	{
		query_ ="cc";
		clear_bit(1 );
	}
	string query()
	{
		return query_;
	}
	void set_query(string value )
	{
		set_bit(1 );
		query_ =value;
	}
	void set_query(string value, size_t size )
	{
		set_bit(1 );
		query_ =value[0 .. size];
	}
	string mutable_query()
	{
		set_bit(1 );
		return query_.dup;
	}
	int quersy()
	{
		return quersy_;
	}
	bool has_quersy()
	{
		return has_bit(2 );
	}
	void clear_quersy()
	{
		quersy_ =1;
		clear_bit(2 );
	}
	void set_quersy(int value )
	{
		set_bit(2 );
		quersy_ =value;
	}
	byte[] Serialize()
	{
		byte[] rst;
		if(has_query )
			rst ~= toByteString(query(), 1, Type.TYPE_BYTES );
		if(has_quersy )
			rst ~= toVarint(quersy(), 12, Type.TYPE_INT32 );
		rst ~= _unknown_fields;
		return rst;
	}
	static SearchRequest Deserialize(ref byte[] input )
	{
		return new SearchRequest(input );
	}
	this()
	{
		
	}
	this(ref byte[] input )
	{
		while(input.length>0 )
		{
			uint tag = GetTag(input );
			byte[] value = GetFieldValue(input, tag );
			switch(GetTagFieldNumber(tag ))
			{
				case 1:
if(GetTagWireType(tag )!=GetWireTypeForFieldType(Type.TYPE_BYTES ))
					throw new Exception("message not match" );
				set_query(cast(string )value );
				break;
				case 12:
if(GetTagWireType(tag )!=GetWireTypeForFieldType(Type.TYPE_INT32 ))
					throw new Exception("message not match" );
				set_quersy(cast(int )Decode!(uint )(value ));
				break;
				default:
 _unknown_fields ~=EncodeBuf(tag )~value ;
			}
		}
}
}
